package com.ruoyi.web.controller.combat.useralignment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.useralignment.CombatRelationWb;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.useralignment.CombatRelationZh;
import com.ruoyi.combat.service.useralignment.ICombatRelationZhService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 知乎用户社交关系
Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/combat/relationzh")
public class CombatRelationZhController extends BaseController
{
    @Autowired
    private ICombatRelationZhService combatRelationZhService;

    /**
     * 查询知乎用户社交关系
列表
     */
    @PreAuthorize("@ss.hasPermi('combat:relationzh:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatRelationZh combatRelationZh)
    {
        startPage();
        List<CombatRelationZh> list = combatRelationZhService.selectCombatRelationZhList(combatRelationZh);
        return getDataTable(list);
    }

    /**
     * 导出知乎用户社交关系
列表
     */
    @PreAuthorize("@ss.hasPermi('combat:relationzh:export')")
    @Log(title = "知乎用户社交关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatRelationZh combatRelationZh)
    {
        List<CombatRelationZh> list = combatRelationZhService.selectCombatRelationZhList(combatRelationZh);
        ExcelUtil<CombatRelationZh> util = new ExcelUtil<CombatRelationZh>(CombatRelationZh.class);
        util.exportExcel(response, list, "知乎用户社交关系数据");
    }

    /**
     * 获取知乎用户社交关系
详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:relationzh:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatRelationZhService.selectCombatRelationZhById(id));
    }

    /**
     * 新增知乎用户社交关系

     */
    @PreAuthorize("@ss.hasPermi('combat:relationzh:add')")
    @Log(title = "知乎用户社交关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatRelationZh combatRelationZh)
    {
        return toAjax(combatRelationZhService.insertCombatRelationZh(combatRelationZh));
    }

    /**
     * 修改知乎用户社交关系

     */
    @PreAuthorize("@ss.hasPermi('combat:relationzh:edit')")
    @Log(title = "知乎用户社交关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatRelationZh combatRelationZh)
    {
        return toAjax(combatRelationZhService.updateCombatRelationZh(combatRelationZh));
    }

    /**
     * 删除知乎用户社交关系

     */
    @PreAuthorize("@ss.hasPermi('combat:relationzh:remove')")
    @Log(title = "知乎用户社交关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatRelationZhService.deleteCombatRelationZhByIds(ids));
    }


    /**
     * 查询用户的关注/粉丝
     */
    @ApiOperation(value = "查询用户社交关系列表")
    @PreAuthorize("@ss.hasPermi('system:relation:list')")
    @GetMapping("/user/{userId}")
    public TableDataInfo list(@PathVariable String userId, @RequestParam(required = false) String plate,
                              @RequestParam(required = false) String relation) {
        startPage();
//        CombatRelation combatRelation = new CombatRelation(null, userId, null, relation, null, plate);
        List<CombatRelationZh> list = combatRelationZhService.selectRelationByUserId(userId);
        return getDataTable(list);
    }



}
